package org.easyelf.springmvc.plugins.easyui;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class DataGrid<T> implements java.io.Serializable {

//	public static interface OnlyIdView {}
//	public static interface OnlyNameView {}
//	public static interface AllView extends OnlyIdView, OnlyNameView {}

    //	@JsonView(OnlyIdView.class)
    public int rows = 0;
    public int page;
    private String sort = ""; //signdate
    private String order = ""; //desc
    private boolean isAsc = false;

    //	@JsonView(OnlyNameView.class)
    public List<T> records = new ArrayList<T>();

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    public boolean isAsc() {
        if(StringUtils.isNotBlank(getOrder())&&getOrder().equals("asc")){
            isAsc = true;
        }
        return isAsc;
    }

    public void setAsc(boolean asc) {
        isAsc = asc;
    }
}
